import pygame
image=pygame.image.load("ledge.jpg")
image.set_colorkey((137,44,75))
import Platform

class Ledge(Platform.Platform):
	def __init__(self,pos=(0,0)):
		Platform.Platform.__init__(self,pos,image)
	def drawingInformation(self):
		return self.pos,self.image
	def hasFallenOff_y(self,objecto):
		if self.pos[1]<objecto.y+objecto.getHeight() or self.pos[1]>objecto.y+objecto.getHeight():
			self.unbound(objecto)
		elif self.pos[0]>objecto.x-0.5*objecto.getWidth():
			objecto.x=self.pos[0]+0.5*objecto.getWidth()
		elif objecto.x+0.5*objecto.getWidth()>self.pos[0]+self.getWidth():
			objecto.x=self.pos[0]+self.getWidth()-0.5*objecto.getWidth()
	def within_x_boundary(self,ox,ow):
		return Platform.Platform.within_x_boundary(self,ox,ow,k=0.25)
		#self.pos[0]<=ox+0.25*ow and ox-0.25*ow<=self.pos[0]+self.getWidth()
	def isThin(self):
		return True
	def xLanding(self,objecto):
		pass
	"""def upperSide(self):
		return self.pos[1]
	def lowerSide(self):
		return self.pos[1]#-self.getHeight()
	def reaction_up(self,objecto):
		if objecto.isAlive():
			x1=objecto.x
			objecto.reposition(x1,self.pos[1]-objecto.getHeight())
			objecto.y_bound=self
			self.boundedList.append(objecto)
	def reaction_down(self,objecto):
		if objecto.isAlive():
			x1=objecto.x
			objecto.reposition(x1,self.pos[1]-objecto.getHeight())
			objecto.y_bound=self
			self.boundedList.append(objecto)"""
	def yLanding(self,objecto):
		if self.within_x_boundary(objecto.x,objecto.getWidth()) and (objecto.y+objecto.getHeight()<=self.pos[1]<objecto.prev_y+objecto.getHeight()):
			if objecto.isAlive():
				objecto.reposition(objecto.x,self.pos[1]-objecto.getHeight())
				self.boundY(objecto,False)
		elif self.within_x_boundary(objecto.x,objecto.getWidth()) and (objecto.prev_y+objecto.getHeight()<=self.pos[1]<=objecto.y+objecto.getHeight()):
			if objecto.isAlive():
				objecto.reposition(objecto.x,self.pos[1]-objecto.getHeight())
				self.boundY(objecto,False)
	def pointOfPlatform(self,x,y):
		return y==self.pos[1] and self.within_x_boundary(x,0)